﻿using mds.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace mds.DistributedRelay
{
    public class CacheConfigService
    {
         private static CacheConfigService _instance = new CacheConfigService();
         private CacheConfigItem _Configuration;

        public static CacheConfigService Instance
        {
            get { return _instance; }         
        }
        private CacheConfigService()
        {
            _Configuration = ConfigurationManager.Instance.GetService<CacheConfigItem>("CacheService");
        }
        public CacheConfigItem GetConfig()
        {
            return _Configuration;
        }
        public CacheServerItem GetConnection()
        {
            var rad = new Random(1);
            return _Configuration.Servers.ElementAt(rad.Next(0, (_Configuration.Servers.Count - 1)));
        }
    }
}
